cmake_minimum_required(VERSION 3.1)
if(EXISTS /usr/bin/clang AND EXISTS /usr/bin/clang++)
   set(CMAKE_C_COMPILER /usr/bin/clang)
   set(CMAKE_CXX_COMPILER /usr/bin/clang++)
endif()
project(SerialPort)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQIRED ON)
set(PROJECT_ROOT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(TEST_PATH ${CMAKE_CURRENT_LIST_DIR}/test)
message(STATUS "##########${CMAKE_SYSTEM_NAME}#########")
if(CMAKE_SYSTEM_NAME MATCHES "Linux")

elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
    set(OpenCV_DIR /usr/local/opt/opencv@3/share/OpenCV)
endif()

add_definitions(-DROOT_PATH="${CMAKE_CURRENT_LIST_DIR}")
# Compile Depend modules########
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/libBase)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/libHardware)

include_directories(${BASE_INCLUDE})
include_directories(${HARDWARE_INCLUDE})


set(HARDWARE_LIB SerialPort motorcontrol)
set(WMJ_LIBRARIES Base ${HARDWARE_LIB})

# test###########
macro(add_test_file TEST_FILE)
    add_executable(${TEST_FILE} ${TEST_PATH}/${TEST_FILE}.cpp)
    target_link_libraries(${TEST_FILE} ${WMJ_LIBRARIES})
endmacro()

add_test_file(SendTest)
add_test_file(ConstantMove)
